package com.leadnews.controller;

import com.leadnews.pojo.Order;
import com.leadnews.service.OrderService;
import com.leadnews.vo.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/order")
@CrossOrigin(origins = "*",maxAge = 3600)
@Slf4j
public class OrderController {
    @Autowired
    OrderService orderService;
    @PostMapping("/publish")
    public ResponseResult publish(@RequestBody Order order, HttpServletRequest request){
        log.info(order.toString());
        return orderService.publish(order,request);
    }
    @PostMapping("/selectOrder")
    public ResponseResult selectOrder(@RequestBody Map<String,String> map, HttpServletRequest request){
        return orderService.selectOrder(map,request);
    }
    @PostMapping("/deleteOrder")
    public ResponseResult deleteOrder(@RequestBody Order order, HttpServletRequest request){
        return orderService.deleteOrder(order,request);
    }
}
